import requests
import baozou_insert_sql
import re
Platform = "微小宝"
def weixiaobao():
    r = requests.session()
    url="https://account.wxb.com/login?from=http%3A%2F%2Fxs.wxb.com%2Findex"
    data = {
        "email": "",
        "password": "",
        "captcha": "",
        "from": "http://xs.wxb.com/index"
    }
    header = {
        "referer": "https://account.wxb.com/?from=http%3A%2F%2Fxs.wxb.com%2Findex",
        "user-agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36",
        "x-requested-with": "XMLHttpRequest"
    }
    rr = r.post(url=url,data=data,headers =header)

    aa = r.get(url="http://xs.wxb.com/collect")

    ht = aa.text
    html = ht.replace('\r','').replace('\t','').replace('\n','')
    date_time_list = re.findall('<tbody.*?<tr.*?<tr.*?<span.*?</span><!--.*?<!--.*?>(.*?)<!.*?</td>',html)
    date_time =date_time_list[0]

    Amount_share_list = re.findall('<tbody.*?<tr.*?<tr.*?<td.*?<td.*?<!--.*?>(.*?)<!.*?</td>',html)
    Amount_share = int(Amount_share_list[0])*0.9
    Amount_share = round(Amount_share, 2)

    baozou_insert_sql.baozou_spider_everyday_sum(date_time,Amount_share,Platform)
